package day09;

import java.util.Scanner;

public class homework01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count=0;
        big:while (true) {
            student s=new student();
            System.out.println("请输入学生姓名-年龄,若输入多个,请空格隔开");
            String str = sc.nextLine();
            String[] stus=str.split(" ");
            for (int i=0;i<stus.length;i++) {
                try {
                    String stu=stus[i];
                    s.setName(stu.split("-")[0]);
                    s.setAge(Integer.parseInt(stu.split("-")[1]));
                } catch (StudentInitnameException | StudentInitageException e) {
                    System.out.println(e);
                } catch (NumberFormatException e) {
                    System.out.println("年龄输入格式非法，请输入整数");
                } finally {
                    System.out.println(s);
                    count++;
                }
                if (i==2){
                    break big;
                }
                if (count==3){
                    break big;
                }
            }
        }
    }
}
